package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.ExpirationReminderSetup;
import com.ruoyi.contract.service.IExpirationReminderSetupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同到期提醒设置Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/ExpirationReminderSetup")
public class ExpirationReminderSetupController extends BaseController
{
    @Autowired
    private IExpirationReminderSetupService expirationReminderSetupService;

    /**
     * 查询合同到期提醒设置列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpirationReminderSetup expirationReminderSetup)
    {
        startPage();
        List<ExpirationReminderSetup> list = expirationReminderSetupService.selectExpirationReminderSetupList(expirationReminderSetup);
        return getDataTable(list);
    }

    /**
     * 导出合同到期提醒设置列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:export')")
    @Log(title = "合同到期提醒设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpirationReminderSetup expirationReminderSetup)
    {
        List<ExpirationReminderSetup> list = expirationReminderSetupService.selectExpirationReminderSetupList(expirationReminderSetup);
        ExcelUtil<ExpirationReminderSetup> util = new ExcelUtil<ExpirationReminderSetup>(ExpirationReminderSetup.class);
        util.exportExcel(response, list, "合同到期提醒设置数据");
    }

    /**
     * 获取合同到期提醒设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:query')")
    @GetMapping(value = "/{expirationReminderSetupId}")
    public AjaxResult getInfo(@PathVariable("expirationReminderSetupId") Long expirationReminderSetupId)
    {
        return success(expirationReminderSetupService.selectExpirationReminderSetupByExpirationReminderSetupId(expirationReminderSetupId));
    }

    /**
     * 新增合同到期提醒设置
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:add')")
    @Log(title = "合同到期提醒设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpirationReminderSetup expirationReminderSetup)
    {
        return toAjax(expirationReminderSetupService.insertExpirationReminderSetup(expirationReminderSetup));
    }

    /**
     * 修改合同到期提醒设置
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:edit')")
    @Log(title = "合同到期提醒设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpirationReminderSetup expirationReminderSetup)
    {
        return toAjax(expirationReminderSetupService.updateExpirationReminderSetup(expirationReminderSetup));
    }

    /**
     * 删除合同到期提醒设置
     */
    @PreAuthorize("@ss.hasPermi('contract:ExpirationReminderSetup:remove')")
    @Log(title = "合同到期提醒设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{expirationReminderSetupIds}")
    public AjaxResult remove(@PathVariable Long[] expirationReminderSetupIds)
    {
        return toAjax(expirationReminderSetupService.deleteExpirationReminderSetupByExpirationReminderSetupIds(expirationReminderSetupIds));
    }
}
